package com.itjeffrey.autocode.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itjeffrey.autocode.bo.UserInfoBO;
import com.itjeffrey.autocode.bo.req.IsEnableBO;
import com.itjeffrey.autocode.bo.req.RelateRoleBO;
import com.itjeffrey.autocode.entity.UserInfoEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @From: Jeffrey
 * @Date: 2020/12/9
 */
public interface UserInfoMapper extends BaseMapper<UserInfoEntity> {

    String getAvaUrl(@Param("loginName") String loginName);

    @Update("update user_info_tb set ava_url = #{avaUrl} where username = (select user_name from login_info_tb where " +
            "login_name = #{loginName})")
    int updateAvaUrl(@Param("avaUrl") String avaUrl, @Param("loginName") String loginName);

    @Select("select user_name from login_info_tb where login_name = #{loginName}")
    String getUserNameByLoginName(@Param("loginName") String loginName);

    List<UserInfoBO> selectUserList(UserInfoBO userInfoBO);

    int isEnable(IsEnableBO isEnableBO);

    UserInfoBO queryOne(@Param("loginname") String loginname);

    int deleteUserRole(@Param("username") String username);

    int relateRole(RelateRoleBO relateRoleBO);
}
